<?php

namespace LaraPress\Config;

use Redux_Taxonomy;
use ReduxFramework;

class LaraPressTerm
{
    public static $opt_name = 'lara_press_term_opt';

    public function __construct()
    {
        $this->init();
    }

    static function get_option($id, $key = false, $default = null)
    {
        $value =  Redux_Taxonomy::get_term_meta([
            'key' => $key,
            'opt_name' => self::$opt_name,
            'taxonomy' => $id,
        ]);
        if ($value) {
            return $value;
        }
        return $default;
    }

    public function init()
    {

        Redux_Taxonomy::set_args(
            self::$opt_name,
            array(
                'taxonomy_priority' => 55,
                'dev_mode' => false,
            ),
        );

        Redux_Taxonomy::set_term(
            self::$opt_name,
            array(
                'id'             => "larapress_term_settings",
                'title'          => "Larapress Term设置",
                'taxonomy_types' => array('category', 'post_tag'),
                'sidebar'        => false,
                'style'          => 'wp',
                'add_visibility' => true,
                'sections'       => array(
                    array(
                        'title'  => "基础设置",
                        'icon'   => 'el-icon-home',
                        'fields' => array(
                            array(
                                'id'             => 'tax-text-1',
                                'type'           => 'text',
                                'add_visibility' => true,
                                'title'          => esc_html__('Test Input', 'your-textdomain-here'),
                            ),
                            array(
                                'id'    => 'tax-text-2',
                                'type'  => 'text',
                                'title' => esc_html__('Test Input2', 'your-textdomain-here'),
                            ),
                        )
                    ),
                    array(
                        'title'  => "基础设置",
                        'icon'   => 'el-icon-home',
                        'fields' => array(
                            array(
                                'id'             => 'cover',
                                'type'           => 'media',
                                'add_visibility' => true,
                                'title'          => '封面',
                            ),

                        )
                    ),
                )
            )
        );
    }
}
